package com.amoqi.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;

public class AjaxController extends Controller {
	public void index(){
		render("index.jsp");
	}
	/**
	 * get方式的ajax请求
	 */
	@SuppressWarnings("unchecked")
	public void get(){
		String param = getPara("param");
		Ret ret = Ret.create();
		ret.put("success", true);
		ret.put("param", param);
		ret.put("type", "get");
		ret.put("message", "data");
		renderJson(ret);
	}
	/**
	 * post方式的ajax请求
	 */
	@SuppressWarnings("unchecked")
	public void post(){
		String param = getPara("param");
		Ret ret = Ret.create(); 
		ret.put("success", true);
		ret.put("type", "post");
		ret.put("param", param);
		ret.put("message", "data");
		renderJson(ret);
	}
	/**
	 * form方式的ajax请求
	 */
	public void form(){
		String param = getPara("param");
		String a = getPara("a");
		String b = getPara("b");
		String c = getPara("c");
		setAttr("param",param);
		setAttr("a",a);
		setAttr("b",b);
		setAttr("c",c);
		renderJson();
	}
}
